#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
int g_val = 0;
int main()
{
  pid_t id = fork();
  if(id == 0)
  {
    g_val = 100;
    int i = 5;
    while(i--)
    {
      printf("我是子进程，g_val值为:%d，g_val的地址：%p\n",g_val,&g_val);
      sleep(1);
    }
  }
  else
  {
    int i=5;
    while(i--)
    {
      printf("我是父进程，g_val值为:%d，g_val的地址为：%p\n",g_val,&g_val);
      sleep(1);
    }
  }
  return 0;                                                                                                                       }
